// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

// Upgrade NOTE: commented out 'float4x4 _Object2World', a built-in variable
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
// Upgrade NOTE: replaced 'glstate_matrix_mvp' with 'UNITY_MATRIX_MVP'


Shader  "Custom/FresnelFade" {

	Properties
	 {
 _Color ("_Color", Color) = (1,0,0,1)
 _FresnelColor ("_FresnelColor", Color) = (0,1,0,1)
 _ColorAdd ("_ColorAdd", Color) = (0,0,0,1)
 _Blend ("_Blend", Float) = 0
}

	

	SubShader
     {
  Tags { "QUEUE"="Transparent" }
  Blend SrcAlpha OneMinusSrcAlpha

    LOD 100
	Pass
	{
	
	

	CGPROGRAM
	#pragma vertex vert
	#pragma fragment frag
	#include "UnityCG.cginc"

	struct VertexInput {
    fixed4 vertex : POSITION;
	fixed2 xlv_TEXCOORD0 : TEXCOORD0;
    //fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    //fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    //fixed3 xlv_TEXCOORD3 : TEXCOORD3;
    //fixed4 tangent : TANGENT;
    fixed3 normal : NORMAL;
    fixed3 xlv_COLOR0 : COLOR;
	//VertexInput
	};


	struct VertexOutput {
	fixed4 pos : SV_POSITION;
    UNITY_FOG_COORDS(1)
    //fixed3 xlv_COLOR0 : COLOR;
	fixed xlv_TEXCOORD0 : TEXCOORD0;
    fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    //fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    //fixed3 xlv_TEXCOORD3 : TEXCOORD3;
	//VertexOutput
	};

	

 
 
 
 // float4x4 _Object2World;


	

 float4 _Color;
 float4 _ColorAdd;
 float4 _FresnelColor;
 float _Blend;
 float xlv_TEXCOORD;




	VertexOutput vert (VertexInput v)
	{
	VertexOutput o;
	//o.pos = UnityObjectToClipPos (v.vertex);
	//o.xlv_TEXCOORD0 = TRANSFORM_TEX(v.xlv_TEXCOORD0, _MainTex);
	
  float4 tmpvar_1;
  tmpvar_1.w = 0.0;
  tmpvar_1.xyz = normalize(v.normal);
  float4 normal4_2;
  float4 tmpvar_3;
  normal4_2.xyz = tmpvar_1.xyz;
  normal4_2.w = 0.0;
  tmpvar_3.xyz = tmpvar_1.xyz;
  tmpvar_3.w = 1.0;
  o.pos = UnityObjectToClipPos( v.vertex);
  o.xlv_TEXCOORD0 = ((0.5 * dot (
    mul(unity_ObjectToWorld , normal4_2)
  .xyz, fixed3(1.0, -1.0, 1.0))) + 1.0);
  o.xlv_TEXCOORD1 = tmpvar_3;




    UNITY_TRANSFER_FOG(o,o.vertex);
   
	return o;
	}


	fixed4 frag(VertexOutput i) : SV_Target
    {
    //fixed4 tmpvar_2 = tex2D(_MainTex, i.uv);
	//UNITY_APPLY_FOG(i.fogCoord, tmpvar_2);
	
  float4 returnColor_1;
  returnColor_1 = _ColorAdd + lerp (_Color, _FresnelColor, float4(i.xlv_TEXCOORD0, i.xlv_TEXCOORD0, i.xlv_TEXCOORD0, i.xlv_TEXCOORD0));
  returnColor_1.w = _Blend;
  return returnColor_1;

	}
	ENDCG
	}
  }
  Fallback "Diffuse"
}

